<!--
 * @Date: 2023-01-04 14:31:10
 * @LastEditTime: 2023-06-07 16:31:31
-->
<template>
  <router-view v-if="isActive" />

  <langSelect
    ref="selectRef"
    :query="query"
    @getData="setData"
    @selectChange="selectChange"
  />
</template>
<script setup>
import { getCurrentInstance, onMounted, nextTick, ref } from "vue";

const instance = getCurrentInstance();
const { proxy } = instance;

const query = ref({ account_id: 1, project_name: "test" }),
  // 页面路由是否响应
  isActive = ref(false),
  // 接收SDK返回数据
  setData = () => {
    const { details, selectValue } = proxy.$refs.selectRef;

    isActive.value = true;
    instance.appContext.config.globalProperties.$details = details;
    instance.appContext.config.globalProperties.$language = selectValue;
  },
  // 语言下拉框变更处理
  selectChange = () => {
    isActive.value = false;
    setTimeout(() => {
      setData();
      isActive.value = true;
    }, 0);
  };
</script>
